<template>
    <ListPage ref="page" :query="query" :api="getDlrZzhList">
        <template #search="{ page, hiddenColumns }">
            <PageSearch ref="search" :query="query" :page="page" has-box @search="() => ($refs.page as any).getData()">
                <template #auth>
                </template>
                <template #input="{ }">
                    <ElFormItem label="日期" style="display: inline-block; margin-right: 10px;">
                        <ElDatePicker v-model="query.date" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD" clearable />
                    </ElFormItem>
                    <ElButton type="primary" @click="searchData">搜索</ElButton>
                </template>
            </PageSearch>
        </template>

        <template #table="{ data, hiddenColumns }">
            <ListTable :data="data" :hidden-columns="(hiddenColumns as any)" @openSjLr="openSjLr">
            </ListTable>
        </template>
    </ListPage>
</template>

<script setup lang="ts">
import ListPage from '@/components/list-page/ListPage.vue'
import PageSearch from '@/components/list-page/PageSearch.vue'
import { ref, reactive } from 'vue'
import { getDlrZzhList } from '../api'
import ListTable from './ListTable.vue'
import { sjlrDialog } from '../dialog/sjlrDialog'
import { getYesterDay } from '@/utils/zeo'

const query = reactive({
    keyword: '',
    date: getYesterDay()
})

const page = ref()

const searchData = async () => {
    page.value.getData()
}

const openSjLr = async (row) => {
    await sjlrDialog.title('数据录入').open({
        row:
        {
            date: row.date,
            sjzh: row.sjzh,
            zzhmc: row.zzhmc,
            fpKfId: row.fpKfId,
            zzhId: row.zzhId
        }
    });
    page.value && page.value.getData();
}



</script>